package model;

import java.util.Date;

import org.joda.time.DateTime;
import org.joda.time.LocalDate;

import services.AlarmClock;
import services.AlarmType;
import utils.Utils;

public class AlarmClockWrapper {

	private Integer id = -1;
	private Integer userid = -1;
	private LocalDate startDate = new LocalDate();
	private LocalDate endDate = new LocalDate();
	private AlarmTypeWrapper type;
	private DateTime time = new DateTime();
	public AlarmClockWrapper() {
	}
	public AlarmClockWrapper(Integer id, Integer userid, Date startDate, Date endDate, Date time, AlarmType type) {
		this.id = id;
		this.userid = userid;
		this.startDate = new LocalDate(startDate);
		this.endDate = new LocalDate(endDate);
		this.time = new DateTime(time);
		this.type = AlarmTypeWrapper.wrap(type);
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public Integer getUserid() {
		return userid;
	}
	public void setUserid(Integer userid) {
		this.userid = userid;
	}
	public LocalDate getStartDate() {
		return startDate;
	}
	public void setStartDate(LocalDate startTime) {
		this.startDate = startTime;
	}
	public LocalDate getEndDate() {
		return endDate;
	}
	public void setEndDate(LocalDate endTime) {
		this.endDate = endTime;
	}
	public DateTime getTime() {
		return time;
	}
	public void setTime(DateTime time) {
		this.time = time;
	}
	
	
	public static AlarmClockWrapper wrap(AlarmClock clock) {
		return new AlarmClockWrapper(clock.getId(), clock.getUserid(), clock.getStartDate().getTime(), clock.getEndDate().getTime(),
				clock.getTime().getTime(), clock.getType());
		}
	public AlarmTypeWrapper getType() {
		return type;
	}
	public void setType(AlarmTypeWrapper type) {
		this.type = type;
	}
	
	public AlarmClock toAlarmClock() {
		return new AlarmClock(Utils.dateToCalendar(endDate.toDate()), id, Utils.dateToCalendar(startDate.toDate()),
							Utils.dateToCalendar(time.toDate()), type.toAlarmType(), userid);
	}
}
